package office.excel.poi.core.impl;
import java.util.Iterator;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import office.excel.poi.core.Sheet;
import office.utils.ObjectUtil;

public class SheetImpl implements Sheet {

    /**
     * 根据表格的内容找到列
     */
	public HSSFCell findCell(HSSFSheet sheet,String s) {
		Iterator<Row> itRows = sheet.rowIterator();
		while (itRows.hasNext()) {
			HSSFRow row = (HSSFRow) itRows.next();
			Iterator<Cell> itCell = row.cellIterator();
			while (itCell.hasNext()) {
				HSSFCell cell = (HSSFCell) itCell.next();
				String val = cell.getStringCellValue();
				if (ObjectUtil.isNotEmpty(val) && val.trim().equals(s)) {
					return cell;
				}
			}
		}
		return null;
	}

}
